﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JMT.Data
{
    public class JDiagram : IJModel, IJContainer<JElement>
    {
        private JContainer<JElement> _jElementContainer;

        public IJContainer<JDiagram> Container { get; internal set; }

        public JDiagram()
            : base(JConstString.TDiagram)
        {
            _jElementContainer = new JContainer<JElement>();
        }

        #region element container
        public void Add(JElement jModel)
        {
            _jElementContainer.Add(jModel);
            jModel.Container = this;
        }

        public void Remove(JElement jModel)
        {
            jModel.Container = null;
            _jElementContainer.Remove(jModel);
        }

        public JElement Get(Guid id)
        {
            return _jElementContainer.Get(id);
        }

        public List<JElement> ToList()
        {
            return _jElementContainer.ToList();
        }

        public void Register(JContainerUpdate<JElement> update)
        {
            _jElementContainer.Register(update);
        }
        #endregion
    }
}
